<?php
namespace app\api\validate;

use think\Validate;

/**
 * 行为验证器
 * @package app\menus\validate
 * @author
 */
class Address extends Validate
{
    //定义验证规则
    protected $rule = [
        'id|ID'  => 'require|number',
        'name|姓名'  => 'require|length:1,6',
        'phone|手机号'  => 'require|mobile',
        'pro_id|省'  => 'require|number',
        'city_id|市'  => 'require|number',
        'dist_id|区'  => 'require|number',
        'address|详细地址'  => 'require',
        'is_check|是否默认'  => 'require|number',
    ];
    //定义验证提示
    protected $message = [
        'id.require' => '无效的数据',
        'id.number' => '无效的数据',
        'name.require' => '请填写姓名',
        'name.length' => '姓名格式不对',
        'phone.require' => '请填写手机号',
        'phone.mobile' => '请填写正确的手机号',
        'pro_id.require' => '请选择省份',
        'pro_id.number' => '省份格式不正确',
        'city_id.require' => '请选择市份',
        'city_id.number' => '市格式不正确',
        'dist_id.require' => '请选择区/县',
        'dist_id.number' => '区/县格式不正确',
        'address.require' => '请填写详细地址',
        'is_check.require' => '请选择是否默认',
    ];
    //定义验证场景
    protected $scene = [
        'add'   =>  ['name','phone','pro_id','city_id','dist_id','address','is_check'],
        'update'   =>  ['id','name','phone','pro_id','city_id','dist_id','address','is_check'],

    ];
}
